package com.ppg.basic.copy;

import org.springframework.beans.BeanUtils;
import org.springframework.cglib.beans.BeanCopier;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;

public class Copier {

    private static BeanCopier beanCopier = BeanCopier.create(User.class, UserVO.class, false);

    public static void main(String[] args) {

        User user = new User();
        user.setId(1L);
        user.setName("1");
        user.setAge(1);
        user.setBirth(null);

        UserVO userVO = new UserVO();
        userVO.setId(2L);
        userVO.setBirth(new Date());

//        beanCopier.copy(user, userVO, null);


//        System.out.println(userVO);


//        BeanUtils.copyProperties(user, userVO);

        try {
            org.apache.commons.beanutils.BeanUtils.copyProperties(userVO, user);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        System.out.println(userVO);

        //4520

        //5620

    }
}
